package com.jsh.erp.datasource.entities;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;
import lombok.EqualsAndHashCode;


import com.jsh.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @Author scott
 * @since 2018-12-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
//@Accessors(chain = true)
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    /**
     * 登录账号
     */
    @Excel(name = "登录账号", width = 15)
    private String username;

    /**
     * 真实姓名
     */
    @Excel(name = "真实姓名", width = 15)
    private String realname;

    /**
     * 密码
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    /**
     * md5密码盐
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String salt;

    /**
     * 头像
     */
    @Excel(name = "头像", width = 15,type = 2)
    private String avatar;

    /**
     * 生日
     */
    @Excel(name = "生日", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    /**
     * 性别（1：男 2：女）
     */
    @Excel(name = "性别", width = 15,dicCode="sex")
    @Dict(dicCode = "sex")
    private Integer sex;

    /**
     * 电子邮件
     */
    @Excel(name = "电子邮件", width = 15)
    private String email;

    /**
     * 电话
     */
    @Excel(name = "电话", width = 15)
    private String phone;

    /**
     * 部门code(当前选择登录部门)
     */
    private String orgCode;

    /**部门名称*/
    private transient String orgCodeTxt;
    /**负责部门*/
    private transient String departIds_dictText;
    /**性别*/
    private transient String sex_dictText;
    /**状态*/
    private transient String  status_dictText;
    /**
     * 状态(1：正常  2：冻结 ）
     */
    @Excel(name = "状态", width = 15,dicCode="user_status")
    @Dict(dicCode = "user_status")
    private Integer status;

    /**
     * 删除状态（0，正常，1已删除）
     */
    @Excel(name = "删除状态", width = 15,dicCode="del_flag")
    @TableLogic
    private Integer delFlag;

    /**
     * 工号，唯一键
     */
    @Excel(name = "工号", width = 15)
    private String workNo;

    /**
     * 职务，关联职务表
     */
    @Excel(name = "职务", width = 15)
    @Dict(dictTable ="sys_position",dicText = "name",dicCode = "code")
    private String post;

    /**
     * 座机号
     */
    @Excel(name = "座机号", width = 15)
    private String telephone;

    /**
     * 创建人
     */
    private String createBy;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新人
     */
    private String updateBy;

    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 同步工作流引擎1同步0不同步
     */
    private Integer activitiSync;

    @TableField(exist = false)
    private JshUserChange jshUserChange;

    /**
     * 身份（0 普通成员 1 上级）
     */
    @Excel(name="（1普通成员 2上级）",width = 15)
    private Integer userIdentity;

    /**
     * 负责部门
     */
    @Excel(name="负责部门",width = 15,dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
    @Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
    private String departIds;

    /**
     * 多租户id配置，编辑用户的时候设置
     */
    private String relTenantIds;

    /**设备id uniapp推送用*/
    private String clientId;

    /**租户tenantId*/
    private Integer tenantId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SysUser sysUser = (SysUser) o;
        return Objects.equals(id, sysUser.id) &&
                Objects.equals(username, sysUser.username) &&
                Objects.equals(realname, sysUser.realname) &&
                Objects.equals(password, sysUser.password) &&
                Objects.equals(salt, sysUser.salt) &&
                Objects.equals(avatar, sysUser.avatar) &&
                Objects.equals(birthday, sysUser.birthday) &&
                Objects.equals(sex, sysUser.sex) &&
                Objects.equals(email, sysUser.email) &&
                Objects.equals(phone, sysUser.phone) &&
                Objects.equals(orgCode, sysUser.orgCode) &&
                Objects.equals(orgCodeTxt, sysUser.orgCodeTxt) &&
                Objects.equals(departIds_dictText, sysUser.departIds_dictText) &&
                Objects.equals(sex_dictText, sysUser.sex_dictText) &&
                Objects.equals(status_dictText, sysUser.status_dictText) &&
                Objects.equals(status, sysUser.status) &&
                Objects.equals(delFlag, sysUser.delFlag) &&
                Objects.equals(workNo, sysUser.workNo) &&
                Objects.equals(post, sysUser.post) &&
                Objects.equals(telephone, sysUser.telephone) &&
                Objects.equals(createBy, sysUser.createBy) &&
                Objects.equals(createTime, sysUser.createTime) &&
                Objects.equals(updateBy, sysUser.updateBy) &&
                Objects.equals(updateTime, sysUser.updateTime) &&
                Objects.equals(activitiSync, sysUser.activitiSync) &&
                Objects.equals(userIdentity, sysUser.userIdentity) &&
                Objects.equals(departIds, sysUser.departIds) &&
                Objects.equals(relTenantIds, sysUser.relTenantIds) &&
                Objects.equals(clientId, sysUser.clientId)&&
                Objects.equals(tenantId, sysUser.tenantId);

    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, realname, password, salt, avatar, birthday, sex, email, phone, orgCode, orgCodeTxt, departIds_dictText, sex_dictText, status_dictText, status, delFlag, workNo, post, telephone, createBy, createTime, updateBy, updateTime, activitiSync, userIdentity, departIds, relTenantIds, clientId,tenantId);
    }

}
